package com.medicalproject.controller;

import com.medical.pojo.Detail;
import com.medical.vo.Rmed;
import com.medicalproject.service.DetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("detail")

public class DetailController {
    @Autowired
    DetailService detailService;

    @RequestMapping("findAll")
    public Rmed findAll(){
        List<Detail> list = detailService.findAll();
        return Rmed.suceessData(list);
    }
    @RequestMapping("findById")
    public Rmed findById(@RequestParam Integer id){
        Detail detail = detailService.findById(id);
        return Rmed.suceessData(detail);
    }
    @RequestMapping("add")
    public void add(@RequestBody Detail detail){
        detail.setStartTime(new Date());
        detail.setStatus(0);
        detailService.add(detail);
    }
    @RequestMapping("update")
    public void update(@RequestBody Detail detail){
        detailService.update(detail);
    }
}
